package com.felix.ocoupon.vo;

import com.felix.ocoupon.constant.DistributeTarget;
import com.felix.ocoupon.constant.OcouponCategory;
import com.felix.ocoupon.constant.ProductLine;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * @author hsufelix
 * @email hsufelix@yeah.net
 * @Date 2020/11/13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OcouponTemplateVO {

    private String name;

    private String logo;

    private String description;

    private String category;

    private Integer productLine;

    private Integer counts;

    private Long userId;

    private Integer target;

    private TemplateRule rule;

    public boolean validate() {
        boolean StringValid = StringUtils.isNotEmpty(name)
                && StringUtils.isNotEmpty(logo)
                && StringUtils.isNotEmpty(description);
        boolean enumValid = null != OcouponCategory.of(category)
                && null != ProductLine.of(productLine)
                && null != DistributeTarget.of(target);
        boolean numValid = counts > 0 && userId > 0;
        return StringValid && enumValid && numValid && rule.validate();


    }
}
